import { baseUrlApi, requestClient, type Result } from '#/api/request';

/** 钩子列表 */
export const getHooks = (params?: object) => {
  return requestClient.get<Result>(baseUrlApi('/admin/hooks'), { params });
};

/** 钩子插件列表 */
export const getHooksPlugins = (hook: string, params?: object) => {
  return requestClient.get<Result>(baseUrlApi(`/admin/hooks/${hook}/plugins`), {
    params,
  });
};

/** 钩子插件排序 */
export const postHooksPluginsOrder = (data?: { list_orders: object }) => {
  return requestClient.put<Result>(
    baseUrlApi('/admin/hooks/plugins/list/order'),
    {
      data,
    },
  );
};

/** 同步钩子 */
export const postHooksSync = () => {
  return requestClient.post<Result>(baseUrlApi('/admin/hooks/sync'));
};
